//
//  EDKeychainTool.swift
//  Demo
//
//  Created by IMac  on 2020/11/18.
//  Copyright © 2020 Evgenii Neumerzhitckii. All rights reserved.
//

import UIKit
import KeychainSwift

private var apr_shuxing_UUIDString: String?
private let apr_shuxing_UUIDKEY = "UUIDKEY"

class APR_KeychainTool: NSObject {
    static func func_getUUID() -> String {
        if let uuid = apr_shuxing_UUIDString  {
            return uuid
        }
        let keychain = KeychainSwift()
        keychain.synchronizable = true
        if let value = keychain.get(apr_shuxing_UUIDKEY) {
            apr_shuxing_UUIDString = value
            return value
        } else {
            let uuidStr: String = UUID().uuidString
            apr_shuxing_UUIDString = uuidStr
            keychain.set(uuidStr, forKey: apr_shuxing_UUIDKEY)
            return uuidStr
        }
    }
}
